package com.example.a14113.intent1;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.content.Intent;
import android.net.Uri;
import android.telephony.PhoneNumberUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;


public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final EditText phoneNum=(EditText)findViewById(R.id.phoneNum);
        final Button button=(Button)findViewById(R.id.Button1);
        button.setOnClickListener((b)  {
                String call=phoneNum.getText().toString();
        if(phoneNumberUtils.isGlobalphoneNumber(call)){
            Intent I=new Intent(Intent.ACTION_CALL, Uri.parse("tel://"+call));
            startActivity(I);
        }
        else{
            Toast.makeText(context:NewDialer_1Activity.this,
            R.string.notify_incorrect_phonenum, Toast.LENGTH_LONG).show();
        }
        });
    }
}
